package com.bwie.service.impl;

import com.bwie.utils.R;
import com.bwie.utils.TokenUtil;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.mapper.ProdAttaMapper;
import com.bwie.pojo.ProdAtta;
import com.bwie.service.ProdAttaService;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: 鑫仔
 * @Date: 2025/7/22 09:45
 * @Description:
 **/
@Transactional
@Service
public class ProdAttaServiceImpl extends ServiceImpl<ProdAttaMapper, ProdAtta> implements ProdAttaService {

    @Autowired
    private HttpServletRequest request;

    @Override
    public R addProdAtta(ProdAtta prodAtta) {

        String token = request.getHeader("token");
        String userName = TokenUtil.getUserName(token);

        prodAtta.setProdId(prodAtta.getProdId());
        prodAtta.setCreateTime(new Date());
        prodAtta.setCreateBy(userName);

        save(prodAtta);

        return R.OK();
    }
}
